package com.shhm.system.controller;

import com.shhm.common.dto.response.AjaxResult;
import com.shhm.common.dto.response.AjaxResultPlus;
import com.shhm.system.dto.request.UserFormVO;
import com.shhm.system.service.LoginService;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;

/**
 * @author JackZ
 * @version 1.0
 * @description: 登录接口
 * @date 2025/7/12 下午6:48
 */
@RestController
@RequestMapping("/public")
public class LoginController {
    @Resource
    private LoginService loginService;

    @PostMapping("/login")
    public AjaxResultPlus login(@RequestBody @DateTimeFormat(pattern = "yyyy-MM-dd") UserFormVO reqUser, HttpServletRequest req) {
        return loginService.getInfo(reqUser,req);
    }

    @GetMapping("/captcha")
    public AjaxResultPlus getCaptcha(HttpServletRequest request) throws IOException {
        return loginService.getCaptcha(request);
    }

    @GetMapping("/logout")
    public AjaxResultPlus loginOut(HttpServletRequest req) {
        return loginService.loginOut(req);
    }
}
